#ifndef _TC1X_H_
#define _TC1X_H_


#include "main.h"





#define CMD_HEADER_HW_ADDRESS   ( 0x02000000 )
#define CMD_TABLE_OFFSET        (      0x400 )
#define RFIS_OFFSET             (   0x104400 )
#define DATA_OFFSET             (   0x105000 )
#define CMD_BUFFER_SIZE         ( 1048576 )
#define MAX_CMD_NUM             32

typedef STATUS (*PFUNC)( ULONG BaseAddr, ULONG Length, ULONG Offset );
#define OPT_TO_WRITE  0
#define OPT_TO_READ   1
#define OPT_TO_CHECK  2
typedef struct _mem_desc{
    ULONG Offset;
    ULONG Length;
}MEM_DESC, *PMEM_DESC;
#define MEM_DESC_NUM 5
typedef struct _cmd_ext{
    UCHAR Slot;
    UCHAR OptType;
    UCHAR Rsvd[ 2 ];
    ULONG Loop;
    ULONG DataLength;
    ULONG Offset;
    MEM_DESC MemTable[ MEM_DESC_NUM ];

}CMD_EXT, *PCMD_EXT;

STATUS TestCase1xEntry( PAHCI_EXT AhciExt );
STATUS TC1_1( PAHCI_EXT AhciExt );
STATUS TC1_2( PAHCI_EXT AhciExt );
STATUS TC1_3( PAHCI_EXT AhciExt );
STATUS TC1_4( PAHCI_EXT AhciExt );
STATUS TC1_5( PAHCI_EXT AhciExt );
STATUS TC1_6( PAHCI_EXT AhciExt );
STATUS TC1_7( PAHCI_EXT AhciExt );
STATUS TC1_8( PAHCI_EXT AhciExt );
STATUS TC1_9( PAHCI_EXT AhciExt );
STATUS TC1_10( PAHCI_EXT AhciExt );
STATUS TC1_11( PAHCI_EXT AhciExt );

STATUS TraversePrdt( PAHCI_EXT AhciExt, PCMD_EXT CmdExt );
STATUS TraversePrdtByMemTable( PAHCI_EXT AhciExt, PCMD_EXT CmdExt );
STATUS ToRead( ULONG BaseAddr, ULONG Length, ULONG Offset );
STATUS ToWrite( ULONG BaseAddr, ULONG Length, ULONG Offset );
STATUS ToCheck( ULONG BaseAddr, ULONG Length, ULONG Offset );
void Wait( ULONG uTime );
void BuildMemDesc( PMEM_DESC MemDesc, ULONG Index );
STATUS ToWriteByUSHORT( ULONG BaseAddr, ULONG Length, ULONG Offset );
STATUS ToCheckByUSHORT( ULONG BaseAddr, ULONG Length, ULONG Offset );
void Permutate( ULONG TotalNum, ULONG StageBase, ULONG Index, PULONG OriginalTable, PULONG NewTable );
void TestPermutate( ULONG Num );
#endif

